﻿using DeepEarth.Core.Data;
using System.Collections.Generic;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Threading;
using System.Linq;
using System.Threading;
using DeepEarth.Map.Core.Clustering;
namespace DeepEarth.Map.Core.Filters
{
    /// <summary>
    /// Add the UIElements corresponding to the incoming viewmodels to the Visual Tree
    /// </summary>
    public class PreRenderer
    {
        public static void Remove(List<ClusterViewModel> removeTargets, Dictionary<ClusterViewModel, UIElement> allElements)
        {
            foreach (var vm in removeTargets)
            {
                // TODO: this check was found to be necessary, but all elements should always contain vm!
                if (allElements.ContainsKey(vm))
                {
                    vm.IsVisible = false;
                    vm.IsClustered = false;
                    vm.ClearCluster();
                }
            }
        }


        public static void Add(List<ClusterViewModel> addTargets, Dictionary<ClusterViewModel, UIElement> referenceElements)
        {

            foreach (ClusterViewModel viewModel in addTargets)
            {
                viewModel.IsVisible = true;
            }

        }
    }
}
